import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import "../mainmenu"
import "../programming"
import Qt.database.sqlite 1.0
import Control.Class 1.0

Item {

    //数据库部件
    SqliteDB{
        id: db;
    }


    MainmenuItem{ id: label
        imagepath: qsTr("../../images/hand.png")
        content: qsTr("手动操作")
        height: 30
        anchors{
            top: parent.top; left: parent.left; right: parent.right
        }
    }

    Rectangle{ id: menu
        height: 50
        color: "gray"
        anchors{
            bottom: parent.bottom; left: parent.left; right: parent.right
        }
    }

    //中间部件
    Rectangle{ id: main
        //布局两排
        Row{
            //点击属性并更改
            GroupBox{
                id: propertyChange
                title: qsTr("点击属性并更改")
                width: main.width*3/5; height: main.height
                ModelPanel{
                    rowCount: 9; columnCount: 2;
                    rowspacing: 2; columnspacing: 2;
                    textHAlign: 0; textVAlign: 1;
                    Component.onCompleted: {
                        db.connectDB();
                        db.getDBData(2, "select Property, Value from HandOperate_Property");
                        db.closeDB();
                        for(var i =0; i< db.strCount(); i++)
                        {
                            textnameList.push(db.getData(i));
                        }
                        resetText()
                    }
                    anchors.fill: parent
                }
            }

            //第二列是一个column
            Column{
                //位置
                GroupBox{
                    id: position
                    title: qsTr("位置")
                    width: main.width*2/5; height: main.height*2/3
                    Text{ id: explain
                        height: 10
                        color: qsTr("blue")
                        text: qsTr("坐标中的位置：WorkObject")
                        anchors{
                            top:parent.top; left: parent.left; right: parent.right;
                            leftMargin: 8; rightMargin: 8;
                        }
                    }
                    ModelPanel{ //id: info;
                        rowCount: 7; columnCount: 2
                        rowspacing: 2; columnspacing: 2
                        textHAlign: 0;
                        Component.onCompleted: {
                            db.connectDB();
                            db.getDBData(2, "select Loc, Value from HandOperate_Loction");
                            db.closeDB();
                            console.log("手动属性个数："+ db.strCount())
                            for(var i=0; i< db.strCount(); i++)
                            {
                                textnameList.push(db.getData(i));
                            }
                            console.log("手动属性个数："+textnameList.length)

                            resetText()
                        }

                        anchors{
                            top: explain.bottom; left: explain.left; right: explain.right;bottom: btn.top
                            topMargin: 4; bottomMargin: 2
                        }
                    }

                    Button{ id: btn
                        height: 30;
                        text: qsTr("位置格式...")
                        anchors{
                            bottom: parent.bottom; left: explain.left; right: explain.right
                            bottomMargin: 3;
                        }
                    }
                }
                //操纵杆方向
                GroupBox{
                    id: operaDirection
                    title: qsTr("操纵杆方向")
                    width: main.width*2/5; height: main.height/3
                }
            }

            anchors.fill: parent
        }

        anchors{
            top: label.bottom; bottom: menu.top; left: parent.left; right: parent.right
            topMargin: 3; bottomMargin: 3; leftMargin: 1; rightMargin: 1
        }
    }
}
